/**
 * 数一下有*构成的等腰三角形的数量
 * 首先预处理每一行的*数量
 * 然后对每一个点预处理它往下的两个腰的长度。
 *          *
 *         * *
 *        *   *
 *       *     .
 * 例如对上面这个点左腰长度是4，右腰长度是3，则 Dij 为3
 * 然后for长度中的每一行，检查一下即可
 * O(N^3)
 */
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;

using llt = long long;
using vi = vector<int>;
using pii = pair<int, int>;

int N, M;
vector<string> Board;
vector<vi> S;
vector<vi> D, Left, Right;

int dfsLeft(int r, int c){
    if(not (0 <= r and r < N and 0 <= c and c < M)) return 0;
    if('.' == Board[r][c]) return Left[r][c] = 0;
    if(-1 != Left[r][c]) return Left[r][c];

    if(r + 1 < N and 0 <= c - 1){
        return Left[r][c] = 1 + dfsLeft(r+1, c-1);
    }

    return Left[r][c] = 1;
}

int dfsRight(int r, int c){
    if(not (0 <= r and r < N and 0 <= c and c < M)) return 0;
    if('.' == Board[r][c]) return Right[r][c] = 0;
    if(-1 != Right[r][c]) return Right[r][c];

    if(r + 1 < N and  c + 1 < M){
        return Right[r][c] = 1 + dfsRight(r+1, c+1);
    }
    return Right[r][c] = 1;
}

llt proc(){
    S.assign(N, vi(M, 0));
    for(int i=0;i<N;++i){
        auto & s = S[i];
        auto & t = Board[i];
        if(t[0] == '*') s[0] = 1;
        for(int i=1;i<M;++i){
            s[i] = s[i - 1];
            if(t[i] == '*') s[i] += 1;
        }
    }

    D.assign(N, vi(M, INT_MAX));
    Left.assign(N, vi(M, -1));
    Right.assign(N, vi(M, -1));
    for(int i=0;i<N;++i)for(int j=0;j<M;++j){
        if('*' == Board[i][j]){
            dfsLeft(i, j);
            dfsRight(i, j);
            D[i][j] = min(Left[i][j], Right[i][j]);
        }
    }

    // for(int i=0;i<N;++i){
    //     for(int j=0;j<M;++j){
    //         if('*' == Board[i][j]){
    //             cout << i << ", " << j << ": " << D[i][j] << endl;
    //         }
    //     }
    //     cout << endl;
    // }

    llt ans = 0;
    for(int i=0;i<N;++i)for(int j=0;j<M;++j){
        if('*' == Board[i][j]){
            auto c = D[i][j];
            if(c > 1){
                for(int r,right,left,need=3,k=1;k<c;++k,need+=2){
                    r = i + k;
                    right = j + k;
                    left = j - k;
                    auto tmp = S[r][right];
                    if(left > 0) tmp -= S[r][left - 1];
                    if(need == tmp){
                        ++ans;
                    }
                }
            }
        }
    }
    return ans;
}

void work(){
    cin >> N >> M;
    Board.assign(N, {});
    for(auto & s : Board) cin >> s;
    cout << proc() << "\n";
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--) work();
    return 0;
}